package br.edu.sistemaacademico.command;

import java.io.Serializable;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.sql.SQLException;
import java.util.List;

import br.edu.sistemaacademico.builder.AlunoDAO;
import br.edu.sistemaacademico.pojo.Aluno;

public class CommandAluno extends UnicastRemoteObject implements Command, Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected CommandAluno() throws RemoteException {
		super();
		// TODO Auto-generated constructor stub
	}
	AlunoDAO alunoDao = new AlunoDAO();

	public  boolean gravar(Object o){
		try{
		Aluno aluno = (Aluno) o;
		alunoDao.gravar(aluno);
		}catch(SQLException e){
			return false;
		}
		return true;
	}
	
	public  List<Object> carregar(String condicao, String tabelasAdd){
		return alunoDao.getAll(condicao, tabelasAdd, "nome");
	}
	
	public  Object carregaObjeto(String condicao, String tabelasAdd){
		return alunoDao.getObject(condicao, tabelasAdd);
	}
	
	public  boolean alterar(Object o){
		Aluno aluno = (Aluno) o;
		try {
			alunoDao.alterar(aluno);
		} catch (SQLException e) {
			return false;
		}
		return true;
	}
	
	public  boolean deletar(Object o){
		Aluno aluno = (Aluno) o;
		alunoDao.deletar(aluno);
		return true;
	}
	
	public  List<Object> getCampos(){
		return alunoDao.getCampos();
	}
}
